// pages/details/details.js
var examplesIcon = require('../../data/examplesIcon.js');
examplesIcon = examplesIcon.examplesIcon;
var examplesShow = require('../../data/examplesShow.js');
examplesShow = examplesShow.examplesShow;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    "location": '',
    "offer": '',
    "title": '',
    "url": '',
    "views": '',
    "locationImg": examplesIcon[1].url,
    "randNum": 0,
  },
  /** 获取随机数 */
  getRandNum() {
    var randNum = this.data.randNum;
    // console.log(typeof(randNum));
    randNum = Math.floor(Math.random() * 20);
    // console.log(randNum);
    // console.log(typeof(randNum));
    return randNum;
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(examplesIcon);
    console.log(examplesShow);
    var randNum = this.getRandNum();
    // console.log(randNum);
    var url = examplesShow[randNum].url;
    // console.log(url);
    var views = examplesShow[randNum].views;
    var title = examplesShow[randNum].title;
    var offer = examplesShow[randNum].offer;
    var location = examplesShow[randNum].location;
    this.setData({
      "location": location,
      "offer": offer,
      "title": title,
      "url": url,
      "views": views,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})